[deprecation] Deprecate FuncCallToMethodCallRector - #8343
Merged
Conversation
…s without breaking code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Deprecates
FuncCallToMethodCallRector.The rule turns a function call into a local method call, but that only works when a matching service is already available in the class, when the method signature lines up and when the function has no side effects. In practice these conditions almost never hold together, so the rule breaks code more often than it helps.
class SomeClass { + public function __construct(private \Namespaced\SomeRenderer $someRenderer) + { + } + public function run() { - view('...'); + $this->someRenderer->render('...'); } }The rule is not part of any set. It has to be configured by hand, and no core, Laravel or Drupal ruleset uses it. A project-specific custom rule is a safer way to do this change.
Notes:
Rector\Transform\ValueObject\FuncCallToMethodCallstays in place, so existing configs do not fatal.NodeFactory::createMethodCall()gets an@apitag, as the last core caller is gone but rector-symfony, rector-doctrine and rector-phpunit still use it.